"use strict";

const Controller = require("egg").Controller;
const {parseTime,checkInput} = require('../utils/index.js')
const uuid = require('uuid');
class BaseController extends Controller {
  async setUserInfo(user){
    this.ctx.userInfo = user;
  }
  getUUID(){
    return uuid.v4();
  }
  parseTime(time, cFormat){
    return parseTime(time, cFormat);
  }
  checkInput({form,bean}){
    return checkInput({form,bean});
  }
  consoleError(e,param){
    if(typeof param =='object'){
      param = JSON.stringify(param)
    }
    console.error(`\x1B[36m 时间：${this.parseTime(Date.now())}\x1B[0m`,`\x1B[31m${this.ctx.request.url}接口异常：${e}\x1B[0m`,`\x1B[33m 参数：${param}\x1B[0m`)
  }
}
module.exports = BaseController;